using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ShivamEMR.Model.Domain.PatientDomain;
using ShivamEMR.Model.DataInterfaces.PatientDataInterf;
using ShivamEMR.Model;

namespace ShivamEMR.Web.Areas.Patient.Controllers
{   
    public class InsuranceCategoryController : Controller
    {
		private readonly IInsuranceCategoryRepository insurancecategoryRepository;

		// If you are using Dependency Injection, you can delete the following constructor
        public InsuranceCategoryController()// : this(new InsuranceCategoryRepository())
        {
            this.insurancecategoryRepository = Registry.RepositoryFactory.GetInsuranceCategoryRepository();
        }

        public InsuranceCategoryController(IInsuranceCategoryRepository insurancecategoryRepository)
        {
			this.insurancecategoryRepository = insurancecategoryRepository;
        }

        //
        // GET: /InsuranceCategory/

        public ViewResult Index()
        {
            return View(insurancecategoryRepository.All);//Including(insurancecategory => insurancecategory.Insurances));
        }

        //
        // GET: /InsuranceCategory/Details/5

        public ViewResult Details(int id)
        {
            return View(insurancecategoryRepository.Find(id));
        }

        //
        // GET: /InsuranceCategory/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /InsuranceCategory/Create

        [HttpPost]
        public ActionResult Create(InsuranceCategory insurancecategory)
        {
            if (ModelState.IsValid) {
                insurancecategoryRepository.Create(insurancecategory);
                insurancecategoryRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }
        
        //
        // GET: /InsuranceCategory/Edit/5
 
        public ActionResult Edit(int id)
        {
             return View(insurancecategoryRepository.Find(id));
        }

        //
        // POST: /InsuranceCategory/Edit/5

        [HttpPost]
        public ActionResult Edit(InsuranceCategory insurancecategory)
        {
            if (ModelState.IsValid) {
                insurancecategoryRepository.Update(insurancecategory);
                insurancecategoryRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }

        //
        // GET: /InsuranceCategory/Delete/5
 
        public ActionResult Delete(int id)
        {
            return View(insurancecategoryRepository.Find(id));
        }

        //
        // POST: /InsuranceCategory/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {
            var ic = insurancecategoryRepository.Find(id);
            insurancecategoryRepository.Delete(ic);
            insurancecategoryRepository.Save();

            return RedirectToAction("Index");
        }
    }
}

